using System;
using System.Collections.Generic;
using System.Text;

namespace OgilvyOne.Utility
{
    public class ConnectionInfo
    {
        // Methods
        public static string DecryptDBConnectionString(string InputConnectionString)
        {
            if (InputConnectionString.Equals(string.Empty))
            {
                return InputConnectionString;
            }
            byte[] bytes = new DataProtector(Store.Machine).Decrypt(Convert.FromBase64String(InputConnectionString), null);
            return Encoding.ASCII.GetString(bytes);
        }

        public static string EncryptDBConnectionString(string encryptedString)
        {
            DataProtector protector = new DataProtector(Store.Machine);
            byte[] bytes = Encoding.ASCII.GetBytes(encryptedString);
            return Convert.ToBase64String(protector.Encrypt(bytes, null));
        }

    }
}
